/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ez2find.manager;

import com.ez2find.model.Area;
import com.ez2find.model.Nick;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.Transaction;

/**
 *
 * @author org.@le
 */
@Stateless
public class NickManagerBean implements NickManagerLocal {

    @PersistenceContext
    private EntityManager em;

    public void create(Nick nick) throws Exception {
        em.persist(nick);
    }

    public void update(Nick nick) throws Exception {
        em.merge(nick);
    }

    public void delete(Nick nick) throws Exception {
        Nick entity = em.merge(nick);
        em.remove(entity);
    }

    public Nick find(long id) {
        return em.find(Nick.class, id);
    }

    public List<Nick> listAll() {
        Query query = (Query) em.createNamedQuery("listAllNicks");
        List<Nick> result = query.getResultList();
        return result;
    }
}
